/**
 * 点
 * */

export default {
    data() {
        return {
            iconDrawTool: require('@/assets/map/toolIcon/point.png')
        }
    },

    methods: {
        onToolPoint() {
            this.handlersDrawToolPoint = new Cesium.ScreenSpaceEventHandler(this.$viewer.scene.canvas)

            this.handlersDrawToolPoint.setInputAction(movement => {
                var cartesian = this.getCatesian3FromPX(movement.position)
                if (cartesian && cartesian.x) {
                    var name = 'DrawToolPoint' + new Date().getTime()
                    var entityPoint = {
                        name: name,
                        eventName: 'DrawTool',
                        position: cartesian,
                        billboard: {
                            image: this.iconDrawTool,
                            horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
                            verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
                            heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
                            width: this.$config.mapConfig.billboardSize,
                            height: this.$config.mapConfig.billboardSize
                        }
                    }
                    entityPoint = this.$viewer.entities.add(entityPoint)
                    this.entitiesDrawTool.set(name, entityPoint)
                }
            }, Cesium.ScreenSpaceEventType.LEFT_CLICK)
        },
        offToolPoint() {
            if (this.handlersDrawToolPoint) {
                this.handlersDrawToolPoint.destroy()
                this.handlersDrawToolPoint = null
            }
        }
    }
}
